#include "ColumnDef.h"
#include "Database.h"
#include "TableSchema.h"

int main(int argc, char* argv[])
{
    Database db("./data");

    TableSchema schema("student");
    schema.addColumn(ColumnDef("id", ColumnType::INT));
    schema.addColumn(ColumnDef("name", ColumnType::TEXT));
    schema.addColumn(ColumnDef("age", ColumnType::INT));


    if (!db.existTable(schema.name())) {
        db.createTable(schema);
        Table tb = db.openTable(schema.name());
        std::vector<std::any> row;
        row.push_back(int(1));
        row.push_back(std::string("Bob"));
        row.push_back(int(18));
        tb.readDataFromDisk();
        for (int i = 0; i < 1000; ++i) {
            tb.insertRow(row);
        }
        tb.flushDataToDisk();
    }

    Table tb = db.openTable(schema.name());
    tb.readDataFromDisk();
    tb.dumpRows();

    return 0;
}